package pl.edu.pw.perg.compinfodb.entities;

public class Connector {

	private Long id;
	// kolejnosc wyswietlania polaczen
	private int positionOut;
	private int positionIn;
	// id connectora elementu zewnetrznego
	private VirtualElement elementOut;
	private VirtualElement cable;
	private VirtualElement elementIn;

	
	public Connector() {

	}

	public Connector(int position, VirtualElement ve, boolean inputElement) {

		if(inputElement){
			positionIn = position;
			elementIn = ve;
			elementOut = new VirtualElement();
		}
		else {	
			positionOut = position;
			elementOut = ve;
			elementIn = new VirtualElement();
		}
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public int getPositionOut() {
		return positionOut;
	}

	public void setPositionOut(int positionOut) {
		this.positionOut = positionOut;
	}

	public int getPositionIn() {
		return positionIn;
	}

	public void setPositionIn(int positionIn) {
		this.positionIn = positionIn;
	}

	public VirtualElement getElementOut() {
		return elementOut;
	}

	public void setElementOut(VirtualElement elementOut) {
		this.elementOut = elementOut;
	}

	public VirtualElement getCable() {
		return cable;
	}

	public void setCable(VirtualElement cable) {
		this.cable = cable;
	}

	public VirtualElement getElementIn() {
		return elementIn;
	}

	public void setElementIn(VirtualElement elementIn) {
		this.elementIn = elementIn;
	}


//	public int compareTo(Connector o) {
//		return !input ? positionIn - o.positionIn : positionOut - o.positionOut; 
//	}

	@Override
	public String toString() {
		String eltOutName = "null";
		if(elementOut != null)
			eltOutName = elementOut.getName();
		String eltInName = "null";
		if(elementIn != null)
			eltOutName = elementIn.getName();
		String cableName = "null";
		if(cable != null)
			eltOutName = cable.getName();
		return "[In] " + eltInName + " | " + positionOut + " | " + cableName + " | " + positionIn + " | [Out]: " + eltOutName;
	}
}

